package com.cherrish;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.Message;

import java.util.concurrent.atomic.AtomicInteger;


/**
 * @author cherrish
 * @time 2018-08-31 14:39
 * @name SinkReceiver
 * @desc:
 */
@EnableBinding(value = Sink.class)
public class SinkReceiver {
    private static final AtomicInteger NUM = new AtomicInteger(0);
    private static Logger log = LoggerFactory.getLogger(SinkReceiver.class);
    @StreamListener(Sink.INPUT)
    public void receive(Message<String> payload) {
        log.info(NUM.getAndIncrement() + " Received : " + payload.getPayload());
    }
}

